#define _CRT_SECURE_NO_WARNINGS   1

#include<iostream>
#include<vector>
using namespace std;

struct ListNode
{
	int val;
	struct ListNode*next;
};

ListNode* CreateList(int a[], int n)
{
	ListNode * rear, *s;
	ListNode *head = new ListNode;
	rear = head;
	for (int i = 0; i < n; i++)
	{
		s = new ListNode;
		s->val = a[i];
		rear->next = s;
		rear = s;
	}
	rear->next = NULL;
	return head;
}

class Solution {
public:
	ListNode* Merge(ListNode* pHead1, ListNode* pHead2)
	{
		if (!pHead1) return pHead2;
		if (!pHead2) return pHead1;
		if (pHead1->val < pHead2->val)
		{
			pHead1->next = Merge(pHead1->next, pHead2);
			return pHead1;
		}
		else
		{
			pHead2->next = Merge(pHead2->next, pHead1);
			return pHead2;
		}
	}
};

int main()
{
	Solution sol;
	int num;
	vector<int>a;
	while (cin >> num)
	{
		a.push_back(num);
		if (cin.get() == '\n')
			break;
	}
	int *b;
	b = new int[a.size()];
	for (int i = 0; i < a.size(); i++)
	{
		b[i] = a[i];
	}
	vector<int>c;
	while (cin >> num)
	{
		a.push_back(num);
		if (cin.get() == '\n')
			break;
	}
	int *d;
	d = new int[c.size()];
	for (int i = 0; i < a.size(); i++)
	{
		d[i] = c[i];
	}
	ListNode *newhead = sol.Merge(CreateList(b, a.size()), CreateList(d, c.size()));
	ListNode *p = newhead;
	while (p->next != NULL)
	{
		cout << p->val << "  ";
		p = p->next;
	}
	cout << endl;
	return 0;
}
